package com.assets.util;

import android.os.Handler;
import android.os.HandlerThread;

import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;

/**
 * @作者(author): WR
 * @创建时间(date): 2022/1/5
 */
public class MyRFIDHandle implements LifecycleObserver {
    private HandlerThread handlerThread = new HandlerThread("RFIDWord");
    private Handler mHandle;

    public MyRFIDHandle() {
        handlerThread.start();
        mHandle = new Handler(handlerThread.getLooper());
    }

    public void post(Runnable runnable) {
        mHandle.post(runnable);
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    public void onDestroy() {
        mHandle.removeCallbacksAndMessages(null);
        handlerThread.quit();
    }

}
